package com.ipet.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ipet.modules.sys.entity.RegistrationEntity;
import com.ipet.modules.sys.service.RegistrationService;
import com.ipet.common.utils.PageUtils;
import com.ipet.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-05-20 18:00:32
 */
@RestController
@RequestMapping("sys/registration")
public class RegistrationController {
    @Autowired
    private RegistrationService registrationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:registration:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = registrationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:registration:info")
    public R info(@PathVariable("id") Integer id){
			RegistrationEntity registration = registrationService.selectById(id);

        return R.ok().put("registration", registration);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:registration:save")
    public R save(@RequestBody RegistrationEntity registration){
			registrationService.add(registration);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:registration:update")
    public R update(@RequestBody RegistrationEntity registration){
			registrationService.updateById(registration);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:registration:delete")
    public R delete(@RequestBody Integer[] ids){
			registrationService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
